#pragma once

#include<vector>

#include"YccMove.h"

namespace YCC
{
	class Number
	{
	public:
		Number(const int& numberLength , const std::vector<int>& limits)
		{
			_datas = std::vector<int*>(numberLength , NULL);
			for(int whichDigit = 0 ; whichDigit < numberLength ; ++whichDigit)
			{
				_datas[whichDigit] = new int[2];
				_datas[whichDigit][0] = 0;
				_datas[whichDigit][1] = 0;
			}
			_limits = limits;
		}
		void increase(bool& noMore)
		{
			const int amountOftypes = _limits.size();
			const int length = _datas.size();
			int index = 0;
			while(1)
			{
				if(index >= length)
				{
					noMore = true;
					return;
				}
				else if(_datas[index][1] < _limits[_datas[index][0]] - 1)
				{
					++_datas[index][1];
					return;
				}
				else
				{
					_datas[index][1] = 0;
					if(_datas[index][0] < amountOftypes - 1)
					{
						++_datas[index][0];
						return;
					}
					else
					{
						_datas[index][0] = 0;
						++index;
					}
				}
			}
		}
		void Get(const int& whichDigit , OrderType& typeToWrite , int& targetToWrite)
		{
			typeToWrite = (OrderType)_datas[whichDigit][0];
			targetToWrite = _datas[whichDigit][1];
		}
	private:
		std::vector<int*> _datas;
		std::vector<int> _limits;
	};
}